
//登录窗口_登陆按钮监视器
import java.awt.event.*;
import javax.swing.*;
public class Client_Login_button1 implements ActionListener{
    Client_Login win;
    Client_Login_button1(Client_Login win){
        this.win = win;
    }
    public void actionPerformed(ActionEvent e) {
        String s1 = win.text1.getText();
        String s2 = win.text2.getText();
        if(s1.equals("")||s2.equals("")) {
            JOptionPane.showMessageDialog(null, "账号和密码不能为空");
        }else {
            try {
                String mess = null;
                Client_Socket.out.writeUTF("我要登录");
                Thread.sleep(2000);     //等2s,给服务器机会
                Client_Socket.out.writeUTF(s1);
                Client_Socket.out.writeUTF(s2);
                mess = Client_Socket.in.readUTF();
                if(mess.equals("登陆成功")) {
                    win.dispose();
                    new Client_Ready();
                }else {
                    JOptionPane.showMessageDialog(null, mess);  //弹窗
                }
            }catch(Exception e1){
                JOptionPane.showMessageDialog(null, "与服务器断开连接");
            }
        }
    }
}